package midderw

import (
	"github.com/gin-gonic/gin"
)

func AuthToken() gin.HandlerFunc {
	return func(c *gin.Context) {
		token := c.Request.Header.Get("x-token")
		if token == "" {
			c.JSON(40, gin.H{
				"code": 10001,
				"msg":  "未登录token不为",
			})
			return
		}

		// 设置 example 变量
		c.Set("example", "12345")

		// 请求前

		c.Next()

		// 请求后
		//latency := time.Since(t)
		//log.Print(latency)
		//
		//// 获取发送的 status
		//status := c.Writer.Status()
		//log.Println(status)
	}
}
